window.onload = function() {
    var objNeedNum = document.getElementsByName("hidNeedNum");
    var objStockNum = document.getElementsByName("hidStockNum");
    for(i = 0; i < objNeedNum.length; i++) {
        var NeedNum = parseInt(objNeedNum[i].value);
        var StockNum = parseInt(objStockNum[i].value);
        if(NeedNum > StockNum) {
            setDisabled("Manufacturing",true);
            setDisabled("txtManufacturingNum",true);
        }
    }
}
function goods_FormulaEdit(strFormulaNo) {
    document.goodsFormulaDetailForm.action = getHost() + "goods/goodsFormula/formulaedit/strFormulaNo/" + strFormulaNo ;
    document.goodsFormulaDetailForm.submit();
}
function goods_back() {
    document.goodsFormulaDetailForm.action = getHost() + "goods/goodsFormulaList/index" ;
    document.goodsFormulaDetailForm.submit();
}
function goods_check() {
    var ManufacturingNum = getValue("txtManufacturingNum");
    var objNeedNum = document.getElementsByName("hidNeedNum");
    var objStockNum = document.getElementsByName("hidStockNum");
    var Fg;
    for(i = 0; i < objNeedNum.length; i++) {
        var NeedNum = parseInt(objNeedNum[i].value )* ManufacturingNum;
        var StockNum = parseInt(objStockNum[i].value);
        if(NeedNum > StockNum) {
            Fg = 1;
            setDisabled("Manufacturing",true);
        } else {}
    }
    if(Fg != 1) {
        setDisabled("Manufacturing",false);
    }
}
function goods_Manufacturing() {
    var ManufacturingNum = getValue("txtManufacturingNum");
    var objNeedNum = document.getElementsByName("hidNeedNum");
    var objGoodsNo = document.getElementsByName("hidGoodsNo");
    var arrNeedNum = new Array();
    var arrGoodsNo = new Array();
    for(i = 0; i < objNeedNum.length; i++) {
        arrNeedNum[i] = String(objNeedNum[i].value * ManufacturingNum);
        arrGoodsNo[i] = objGoodsNo[i].value;
    }
    ajaxRequest(getHost()+"goods/goodsFormulaDetail/manufacturing", {
        "arrNeedNum"       : arrayToJson(arrNeedNum),
        "ProductGoodsNo"   : getValue("hidProductGoodsNo"),
        "arrGoodsNo"       : arrayToJson(arrGoodsNo),
        "ManufacturingNum" : ManufacturingNum
    }, goods_Manufacturing_callBack);
}
function goods_Manufacturing_callBack() {
    var strFormulaNo = getValue("hidFormulaNo");
    document.goodsFormulaDetailForm.action = getHost() + "goods/goodsFormulaDetail/index/formulaNo/" + strFormulaNo;
    document.goodsFormulaDetailForm.submit();
}